<template>
    <div class="layui-fluid">
        <div class="layui-row">
            <form v-model="singleLead">
                <input type="text" style="display: none" v-model="singleLead.id">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>公司</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.company">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>销售线索详情</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.leadsDetail">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>姓名</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.name">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>电话</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.phone">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>电话2</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.extraPhone">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>地址</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.address">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>线索池</label>
                    <div class="layui-input-inline">
                        <select class="layui-input" v-model="singleLead.leadsPool">
                            <option :value="a" v-for="a in poolList" >{{a.text}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>来源</label>
                    <div class="layui-input-inline">
                        <select class="layui-input" v-model="singleLead.clientSource">
                            <option :value="a" v-for="a in sourceList" >{{a}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>销售人员退回原因</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.salesRejectReason">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>最后跟进人</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.leadsOwner">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>领取/分配时间</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.getDispatchTimeText">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>创建人</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.creater">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>创建时间</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.createTimeText"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>最后修改时间</label>
                    <div class="layui-input-inline">
                        <input type="text"  class="layui-input" v-model="singleLead.lastModifyTimeText">
                    </div>
                </div>

                <div style="text-align: center">
                    <button class="layui-btn" @click="submitForm(singleLead)">提交</button>
                </div>
            </form>
        </div>
    </div>
</template>

<script>
    import { mapActions, mapState } from "vuex";
    import service from "../../../src/service";
    export default {
        data(){
            return{
                sourceList:["其他",
                    "客户介绍",
                    "客户来电",
                    "线索池",
                    "公司分配",
                    "400电话",
                    "出差拜访",
                    "微信/QQ",
                    "搜索引擎",
                    "阿里巴巴",
                    "话务员转移"],
                poolList:[
                    {
                       value:"1",
                       text:"1文化纸线索池"
                    },
                    {
                        value:"2",
                        text:"2包装纸线索池"
                    }
                ]
            }
        },
        props:['singleLead'],
        name: "lead-edit",
        methods:{
            submitForm(data){
                var lead = {
                    "id":data.id,
                    "name":data.name,
                    "phone":data.phone,
                    "company":data.company,
                    "leadsDetail":data.leadsDetail,
                    "leadsOwner":data.leadsOwner
                }
                service.instance().put("http://"+window.location.hostname+":8011/lead",lead)
                    .then((response)=> {
                        if(response.data == "1"){
                            this.getleads();
                            this.$layer.alert("修改成功");
                            parent.closeAll()
                        }
                    })
            },
            ...mapActions(["getleads"])
        },
        computed:{

        },
        mounted() {

        }
    }
</script>

<style scoped>

</style>